package com.uniconnector.management.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.uniconnector.management.entity.Menu;
import com.uniconnector.management.repository.MenuRepository;

@Controller
@RequestMapping(path="/menu")
public class MenuController {
	
	@Autowired
	private MenuRepository menuRepository;
	
	@PostMapping(path="/add")
	public @ResponseBody String addNewMenu (@RequestParam String name
			, @RequestParam String email) {

//		Menu n = new Menu();
//		n.set(name);
//		n.setEmail(email);
//		menuRepository.save(n);
		
		return "Saved";
	}

	@GetMapping(path="/all")
	public @ResponseBody Iterable<Menu> getAllMenu() {
		return menuRepository.findAll();
	}

}
